package com.jf.cloud.multishop.feign;
import com.jf.cloud.api.multishop.feign.ShopUserFeignClient;
import com.jf.cloud.api.multishop.vo.ShopUserVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.multishop.service.ShopUserService;
import ma.glasnost.orika.MapperFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Hidden;

import java.util.List;

@RestController
@Hidden
public class ShopUserFeignController implements ShopUserFeignClient {
    @Autowired
    private ShopUserService shopUserService;

    @Autowired
    private MapperFacade mapperFacade;

    @Override
    public ServerResponseEntity<ShopUserVO> getByUserId(Long userId) {
        ShopUserVO shopUserVO = mapperFacade.map(shopUserService.getByUserId(userId),ShopUserVO.class);
        return ServerResponseEntity.success(shopUserVO);
    }

    @Override
    public ServerResponseEntity<List<ShopUserVO>> getImShopUserList(List<Long> userIds) {
        return ServerResponseEntity.success(mapperFacade.mapAsList(shopUserService.listShopUserByUserIds(userIds), ShopUserVO.class));
    }

    @Override
    public ServerResponseEntity<Integer> countAccoutByMobile(String mobile) {
        return ServerResponseEntity.success(shopUserService.countAccoutByMobile(mobile));
    }

    @Override
    public ServerResponseEntity<Long> getShopUserIdByShopId(Long  shopId) {
        return ServerResponseEntity.success(shopUserService.getUserIdByShopId(shopId));
    }
}
